package com.ruoyi.xsp.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.xsp.domain.XspCommentReply;
import com.ruoyi.xsp.mapper.XspCommentReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.xsp.mapper.XspCommentMapper;
import com.ruoyi.xsp.domain.XspComment;
import com.ruoyi.xsp.service.IXspCommentService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 评论Service业务层处理
 * 
 * @author zhiminhu
 * @date 2021-03-01
 */
@Service
public class XspCommentServiceImpl implements IXspCommentService 
{
    @Autowired
    private XspCommentMapper xspCommentMapper;
    @Autowired
    private XspCommentReplyMapper xspCommentReplyMapper;
    /**
     * 查询评论
     * 
     * @param id 评论ID
     * @return 评论
     */
    @Override
    public XspComment selectXspCommentById(Integer id)
    {
        return xspCommentMapper.selectXspCommentById(id);
    }

    /**
     * 查询评论列表
     * 
     * @param xspComment 评论
     * @return 评论
     */
    @Override
    public List<XspComment> selectXspCommentList(XspComment xspComment)
    {
        return xspCommentMapper.selectXspCommentList(xspComment);
    }

    /**
     * 新增评论
     * 
     * @param xspComment 评论
     * @return 结果
     */
    @Override
    public int insertXspComment(XspComment xspComment)
    {
        xspComment.setCreateTime(DateUtils.getNowDate());
        return xspCommentMapper.insertXspComment(xspComment);
    }

    /**
     * 修改评论
     * 
     * @param xspComment 评论
     * @return 结果
     */
    @Override
    public int updateXspComment(XspComment xspComment)
    {
        return xspCommentMapper.updateXspComment(xspComment);
    }

    /**
     * 删除评论对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteXspCommentByIds(String ids)
    {
        return xspCommentMapper.deleteXspCommentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除评论信息
     * 
     * @param id 评论ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteXspCommentById(Integer id)
    {
        xspCommentReplyMapper.deleteXspCommentReplyByCommentId(id);
        return xspCommentMapper.deleteXspCommentById(id);
    }

    /**
     * 批量审核
     * @param ids 批量审核的ID
     * @param status 批量审核的状态
     * @return
     */
    @Override
    public int checkXspCommentByIds(String ids,int status){
        return xspCommentMapper.checkXspCommentByIds(Convert.toStrArray(ids),status);
    }
}
